<?php
/**
 * Created by PhpStorm.
 * User: 12133
 * Date: 2025/3/25
 * Time: 15:24
 */

namespace app\controller;

use app\BaseController;
use think\facade\View;

class Base extends BaseController
{
    protected $page;
    protected $size;
    protected $user;
    protected $lang;
    protected $config = [];
    public function initialize()
    {
        $this->page = input('page',1);
        $this->size = input('size',10);
        $this->init();
    }

    protected function init(){
        $lang = input('lang','cn');
        $this->lang = $lang;
    }

    public function getuniqid(){
        return file_get_contents('./key.log');
    }

    public function view($path,$data = []){
        foreach ($data AS $key => $value){
            View::assign($key,$value);
        }
        return View::fetch($path);
    }

    public function msg($data = [],$msg = '操作成功',$code = 200){
        return json(['code' => $code,'data' => $data,'msg' => $msg],200);
    }
    public function fail($msg = '操作失败',$code = 400,$data = []){
        return $this->msg($data,$msg,$code);
    }
}